package scu.maqiang.matlabcases;

import scu.maqiang.fes.BVPType;
import scu.maqiang.heat.Heat2DT31;
import scu.maqiang.mesh.Mesh2T3;
import scu.maqiang.mesh.MeshFormat;
import scu.maqiang.mesh.ScalarFunc;

public class InhomoHeatConduct {

	public static void main(String[] args) {
		long begin = System.nanoTime();
		String fileName = "matlabMeshes\\InhomoUnitSquare.msh";
		Mesh2T3 mesh2D = new Mesh2T3().readMesh(fileName, MeshFormat.msh);
		double theta = 0.5, T = 0.1, dt = 0.005;
		double ThermalDConductivity = 1.0;
		double MassDensity = 1.0;
		double SpecificHeat = 1.0;
		double Source = 1.0;
		
		Heat2DT31 heat = new Heat2DT31(mesh2D);
		double[] x0 = new double[mesh2D.getNv()];
		ScalarFunc initFunc = (xy, label, param)->label == 2? 1.0:-1.0;
		mesh2D.setFuncValueInElement(initFunc, null, 1.0, x0);
		heat.GeneralHeatProblem(new BVPType[] {BVPType.COMMON, BVPType.CONSIST_MASS},
				ThermalDConductivity, MassDensity * SpecificHeat, Source, 
				new double[] {theta, T, dt}, 
				new int[] {1, 2, 3, 4}, 0.0, 
				null, 0.0, 
				null, 0.0, 0.0, x0, 
				"matlabResults\\InhomoHeatConduct.dat");
		long end = System.nanoTime();
		System.out.println("Solve time: " + (end - begin) / 1.0e9 + " s");
		
	}

}
